package com.jbit.utils;

import com.jbit.dto.DmUser;
import io.jsonwebtoken.Claims;

public class DmToken {
    private String token;//token
    private Long expTime;//过期时间
    private Long genTime;//生成时间

    private DmToken() {
    }

    public static DmToken getToken(DmUser dmUser) {
        DmToken dmToken = new DmToken();
        dmToken.setToken(JwtUtils.generalToken(dmUser));//生成token

        Claims claims = JwtUtils.parseTokenClaims(dmToken.getToken());
        dmToken.setGenTime(claims.getIssuedAt().getTime());
        dmToken.setExpTime(claims.getExpiration().getTime());

        return dmToken;

    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Long getExpTime() {
        return expTime;
    }

    public void setExpTime(Long expTime) {
        this.expTime = expTime;
    }

    public Long getGenTime() {
        return genTime;
    }

    public void setGenTime(Long genTime) {
        this.genTime = genTime;
    }
}
